+2006-07-20 Matthias Clasen <mclasen@redhat.com>
+
+ Fix a thinko that leads to constantly reloading
+ the mime data if a mime.cache is present. Patch
+ by Yevgen Muntyan, bugs.freedesktop.org #7495
+
+ * xdgmime.c (xdg_check_dir): Look for mime.cache first.
+ (xdg_check_file): Report existance of the file separately.
+
2006-07-20 Matthias Clasen <mclasen@redhat.com>
* xdgmime.c (xdg_mime_shutdown): Unref the caches.
* FIXME: This doesn't protect against permission changes.
*/
static int
-xdg_check_file (const char *file_path)
+xdg_check_file (const char *file_path,
+ int *exists)
{
struct stat st;
{
XdgDirTimeList *list;
+ if (exists)
+ *exists = TRUE;
+
for (list = dir_time_list; list; list = list->next)
{
if (! strcmp (list->directory_name, file_path) &&
return TRUE;
}
+ if (exists)
+ *exists = FALSE;
+
return FALSE;
}
xdg_check_dir (const char *directory,
int *invalid_dir_list)
{
- int invalid;
+ int invalid, exists;
char *file_name;
assert (directory != NULL);
- /* Check the globs file */
- file_name = malloc (strlen (directory) + strlen ("/mime/globs") + 1);
- strcpy (file_name, directory); strcat (file_name, "/mime/globs");
- invalid = xdg_check_file (file_name);
+ /* Check the mime.cache file */
+ file_name = malloc (strlen (directory) + strlen ("/mime/mime.cache") + 1);
+ strcpy (file_name, directory); strcat (file_name, "/mime/mime.cache");
+ invalid = xdg_check_file (file_name, &exists);
free (file_name);
if (invalid)
{
*invalid_dir_list = TRUE;
return TRUE;
}
+ else if (exists)
+ {
+ return FALSE;
+ }
- /* Check the magic file */
- file_name = malloc (strlen (directory) + strlen ("/mime/magic") + 1);
- strcpy (file_name, directory); strcat (file_name, "/mime/magic");
- invalid = xdg_check_file (file_name);
+ /* Check the globs file */
+ file_name = malloc (strlen (directory) + strlen ("/mime/globs") + 1);
+ strcpy (file_name, directory); strcat (file_name, "/mime/globs");
+ invalid = xdg_check_file (file_name, NULL);
free (file_name);
if (invalid)
{
return TRUE;
}
- /* Check the mime.cache file */
- file_name = malloc (strlen (directory) + strlen ("/mime/mime.cache") + 1);
- strcpy (file_name, directory); strcat (file_name, "/mime/mime.cache");
- invalid = xdg_check_file (file_name);
+ /* Check the magic file */
+ file_name = malloc (strlen (directory) + strlen ("/mime/magic") + 1);
+ strcpy (file_name, directory); strcat (file_name, "/mime/magic");
+ invalid = xdg_check_file (file_name, NULL);
free (file_name);
if (invalid)
{